package com.chixing.day11_exception;



import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 有关日期的操作
 * java.util.Date
 * 注册时间，下单时间，支付时间
 * 毕业时间，入学时间，生日
 */
public class DateDemo {
    public static void main(String[] args) {
        Date date = new Date(); //当前日期
        //1970.1.1 00:00:00 - 当前对象date相差的毫秒数
        long ms = date.getTime();//
        Date date1 = new Date(ms);
        System.out.println(date1);

        System.out.println(date);
        String date2 = date.toString();
        long xx = date.getTime();
        //1. 比较两个日期的先后顺序
        String date3 = "1999-02-22";
        System.out.println(date3.compareTo(date2));
        //2. 获得当前时间的年月日 时分秒
        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar);

        System.out.println("year:"+calendar.get(Calendar.YEAR));
        System.out.println("month:"+calendar.get(Calendar.MONTH));
        System.out.println("date:"+calendar.get(Calendar.DATE));
        System.out.println("day of month:"+calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println("day of year:"+calendar.get(Calendar.DAY_OF_YEAR));
        System.out.println("day of year:"+calendar.get(Calendar.DAY_OF_WEEK));
        //3. 将 字符串"2000-1-12" 转换成 日期对象
        //Date --->String
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = dateFormat.format(new Date());
        System.out.println(dateStr);

        //String --->Date
        dateStr = "2022-08-01 16:50:26:450";
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        try{
            Date date4 = dateFormat1.parse(dateStr);
            System.out.println(date3);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}


class Resume{
    String customerName;
    String customerUniversityName;
    Date universityStartTime;
    Date universityEndTime;
    Date customerBirthDate;
    Date orderCreatedTime;
    Date orderUpdatedTime;
    Date payTime;
}
